package cn.xugongwei.microserviceconsumer80.controller;

import cn.xugongwei.microservicecommon.entity.UserEntity;
import cn.xugongwei.microservicecommon.service.UserClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xugongwei (isxugongwei(a)gmail.com)
 * @version 1.0
 * @date 2019/4/9 11:58
 */
@RestController
@RequestMapping("/consumer/user")
public class UserController {

    private final UserClientService userClientService;

    @Autowired
    public UserController(UserClientService userClientService) {
        this.userClientService = userClientService;
    }


    @GetMapping("/list")
    public List<UserEntity> list() {
        return userClientService.listUser();
    }

    @GetMapping("/get/{id}")
    public UserEntity get(@PathVariable("id") Integer id) {
        return userClientService.getUserById(id);
    }

}
